<template>
  <div class="">
    <el-card>
      <el-table :data="roles" border style="width: 100%">
        <el-table-column
          type="index"
          label="序号"
          width="120px"
        ></el-table-column>
        <el-table-column prop="title" label="名称"></el-table-column>
        <el-table-column prop="describe" label="描述信息"></el-table-column>
        <el-table-column label="操作" width="120px" fixed="right" #default="{row}">
          <el-button type="primary" size="small" @click="handleClick(row)" v-permission="['distributePermission']">分配权限</el-button>
        </el-table-column>
      </el-table>
    </el-card>

    <distribute-permission v-model="permissionVisible" :roleId="roleId" />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { roleList } from '@/api/role'
import DistributePermission from './components/distribute-permission'
const roles = ref([])
const roleId = ref('')
const permissionVisible = ref(false)
const getRoleLoist = async () => {
  roles.value = await roleList()
}
getRoleLoist()

const handleClick = (row) => {
  roleId.value = row.id
  permissionVisible.value = true
}
</script>

<style lang="scss" scoped></style>
